package com.hospital.hospitalserver.controller;

import com.hospital.hospitalserver.entity.DoctorScheduleRequest;
import com.hospital.hospitalserver.entity.GenerateScheduleRequest;
import com.hospital.hospitalserver.entity.ScheduleDataRequest;
import com.hospital.hospitalserver.service.ScheduleInstanceService;
import com.hospital.hospitalserver.util.Response;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 排班实例控制器API
 * */
@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/schedule")
public class ScheduleInstanceController {
    private final ScheduleInstanceService scheduleInstanceService;

    /**
     * 提交排班实例数据
     * */
    @PostMapping("/generateScheduleInstances")
    public Response generateScheduleInstances(@RequestBody GenerateScheduleRequest generateScheduleRequest){
        return scheduleInstanceService.generateScheduleInstances(generateScheduleRequest);
    }

    /**
     * 排班实例组件中视图数据
     * 加载月视图-周视图-日视图通过请求参数不同在服务层进行选择
     * */
    @PostMapping("/getScheduleInstanceDataBySearch")
    public Response loadScheduleInstancesData(@RequestBody ScheduleDataRequest request){
        return scheduleInstanceService.getScheduleInstancesDataBySearch(request);
    }

    /**
     * 获取今天已排班的科室和医生信息
     * 用于挂号
     * */
    @GetMapping("/getScheduleInstancesDataByCurrentDate")
    public Response getScheduleInstancesDataByCurrentDate(){
        return scheduleInstanceService.getScheduleInstancesDataByCurrentDate();
    }

    /**
     * 根据科室ID和日期查询医生排班信息
     * */
    @PostMapping("/selectDoctorByDepartmentAndDate")
    public Response selectDoctorByDepartmentAndDate(@RequestBody DoctorScheduleRequest request){
        return scheduleInstanceService.selectDoctorByDepartmentAndDate(request);
    }

    /**
     * 根据医生ID查询医生详细信息
     */
    @PostMapping("/selectDoctorDetailById")
    public Response selectDoctorDetailById(@RequestBody DoctorScheduleRequest request){
        return scheduleInstanceService.selectDoctorDetailById(request);
    }
}
